Repository navigation
fix(id/world_ssh): validate the /records drain cursor instead of trusting next_after (#6615) - #6739
Conversation
…non-advancing next_after stops the drain with a notice (#6615)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4dde7a48b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.records_after = Some(after.clone()); | ||
| self.commands | ||
| .push_back(WorldCommand::RecordsContinue { prefix, after }); |
There was a problem hiding this comment.
Track the cursor when its records request is dispatched
When two identical /records commands are pasted in one input frame, recv() queues both initial requests before their continuations, so the drains interleave. After the first drain's second page advances records_after to k2, the second drain's queued continuation still sends after: k1, but its valid next_after: k2 is compared against the shared k2 and falsely rejected as stalled. This clears the drain state and, for listings spanning four or more pages, leaves later pages unfetched. Set records_after from the dequeued RecordsContinue.after when dispatching the request, rather than from a continuation being enqueued, or serialize complete drains.
Useful? React with 👍 / 👎.
Closes #6615
Summary
The SSH
/recordsdrain (pkgs/id/src/world_ssh.rs) trusted the host'snext_afterunchecked:.as_str()collapsed a present-but-non-string cursor toNone— indistinguishable from a legitimate end-of-pages, so a malformed page rendered exactly like a complete listing — and continuation was gated only by the rendered-byte cap, so a repeated or empty cursor re-requested the same page ~18,700 times in the filing's probe. The drain now judges every page's cursor through a factoredrecords_cursor()against the cursor that produced the page (newrecords_aftersession state, reset at drain start and on error):next_after→ listing complete (unchanged);[records truncated: host sent a malformed next-page cursor];""on the first page) → drain stops with[records truncated: host cursor did not advance].A code comment at the validation site records why no separate page-count bound is needed beside the existing byte bound: with strict advance, every continuation moves forward through the host's key space so pages cannot repeat, and the rendered-byte total still caps the drain's size. Oracle: the
world_netrecords cursor contract (#6505/#6578), per the issue's acceptance criteria.Evidence
records_cursor_must_be_a_string_that_advancesdrives the decision with the issue's shapes: absent/null → End; a normal multi-page chain (""→"k1"→"k2"→ end) advances and completes; non-string cursors (123,true, object, array) → Malformed; empty first cursor, repeated cursor, and backwards cursor → Stalled.cargo test --lib --features ssh records_cursor_must_be_a_string_that_advances(laptop, pkgs/id; world_ssh is behind thesshfeature): passed. Fullcargo test --lib --features ssh world_ssh: 37 passed / 0 failed.world_ssh.rs:1014still readvalue["next_after"].as_str()with no advance check in the continuation at :1019-1032.Merge Danger
Door: two-way — client-side drain validation only, single-commit revert.
Blast Radius: SSH command-mode
/recordssessions only. Well-formed hosts (string cursors that advance, null at the end) are unaffected; only malformed or non-advancing cursors change, from a silent fake-complete listing or an ~18,700-request loop to the rendered page plus an explicit truncation notice.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.